package org.example.config;

import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.service.AiServices;
import lombok.extern.slf4j.Slf4j;
import org.example.aiservice.StarRocksAIService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Slf4j
@Configuration
public class AiServiceConfig {

    @Bean
    @Primary
    public StarRocksAIService starRocksAIService(ChatModel ollamaChatModel,
                                                 StreamingChatModel ollamaStreamingChatModel) {
        return AiServices.builder(StarRocksAIService.class)
                .chatModel(ollamaChatModel)  // 用于非流式方法
                .streamingChatModel(ollamaStreamingChatModel)  // 用于流式方法
                .build();
    }
}